package logging;

import java.util.HashMap;
import java.util.Map;

/**
 * 一个全局的上下文对象
 * @author Zhongzhicong
 * @date 2023/3/22 17:13
 * @version：1.0
 */
public class LoggerContext {
    //根logger
    private Logger root;

    //logger缓存,存放解释配置文件后生成的logger 以及通过程序手动创建的logger
    private Map<String, Logger> loggerCache = new HashMap<>();

    public void addLogger(String name, Logger logger) {
        loggerCache.put(name, logger);
    }

    public void addLogger(Logger logger) {
        loggerCache.put(logger.getName(), logger);
    }

    public Logger getRoot() {
        return root;
    }

    public void setRoot(Logger root) {
        this.root = root;
    }

    public Map<String, Logger> getLoggerCache() {
        return loggerCache;
    }

    public void setLoggerCache(Map<String, Logger> loggerCache) {
        this.loggerCache = loggerCache;
    }
}
